home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan 2 / Opus 5 - Magellan 2.iso / Extras / D51_NARexx / Virus_Checker7.dopus5 < prev    next >
Text File  |  1995-12-25  |  7KB  |  194 lines

  1. /* Virus_Checker7 for Directory Opus 5 and Virus_Checker 7.
  2.  By Leo 'Nudel' Davidson for Gods'Gift Utilities
  3.  email: leo.davidson@keble.oxford.ac.uk  www: http://info.ox.ac.uk/~kebl0364/
  4.  
  5. $VER: Virus_Checker7 1.3 (25.12.95)
  6.  
  7.    NOTE: This script _requires_ DOpus v5.11 or above.
  8.    NOTE: This script might work with Virus_Checker 8, but I have only been
  9.          able to test it with an early beta-version (which doesn't work)
  10.          as the PGP signatures fail on all later versions and I haven't been
  11.          able to contact Jon to make sure they're not infected.
  12.  
  13.    If you include the path of a file/dir on the command line, using a {}, only
  14.    this file/dir will be tested. If you omit the {}, the program will check
  15.    all selected files and directories in the SOURCE lister for viruses.
  16.  
  17.    If Virus_Checker's ARexx port is not found, the program will be run for
  18.    you (you should edit the path below). This means the script may fail if
  19.    you give an incorrect path to the Virus_Checker program.
  20.  
  21.    If the Virus_Checker's ARexx port takes over a minute to appear, an error
  22.    requester will appear on the DOpus screen and the script will quit.
  23.  
  24.    If Virus_Checker was running to start with, it will be left running after
  25.    the script has completed. Otherwise, it will be removed from memory.
  26.  
  27.    When a virus is detected a beep will sound and once all files have been
  28.    checked you will get a requester with a list of infected files (including
  29.    the type of virus). It is possible that the requester will fail to
  30.    appear if it becomes too large to fit on the screen. The script will
  31.    detect when this happens and output the results to a shell window instead.
  32.  
  33.    Thanks to John Veldthuis <johnv@tower.actrix.gen.nz> for writting
  34.    Virus_Checker, allowing me access to the VC7 beta versions, and for giving
  35.    me a virus-infected file (!) to test this script with.
  36.  
  37. For a "check selected files for viruses" function, call as:
  38. ------------------------------------------------------------------------------
  39. ARexx        DOpus5:ARexx/Virus_Checker7.dopus5 {Qp} {Ql}
  40. ------------------------------------------------------------------------------
  41. Turn off all switches.
  42.  
  43.  
  44. For an "Un-LhA to a directory and check for viruses" function, call as:
  45. ------------------------------------------------------------------------------
  46. AmigaDOS    C:LHA -M x {fu} {d}{ou-}/
  47. ARexx        DOpus5:ARexx/Virus_Checker7.dopus5 {Qp} {Ql} {d}{o-}
  48. ------------------------------------------------------------------------------
  49. Switches: Do all files
  50.           Output to window
  51.           Rescan dest
  52.           Window close button
  53.  
  54.    v1.00 -> v1.01 - Some minor tidying up.
  55.                     Now checks to make sure the DOPUS.x port exists.
  56.     v1.01 -> v1.2 - Now uses Show() instead of ShowList(). (Thanks Stoebi)
  57.                     Style Guide compliant version numbering and $VER string.
  58.      v1.2 -> v1.3 - Changed the way it loads Virus_Checker into memory as it
  59.                     was causing problems.
  60.  
  61. */
  62. /*- Path to Virus_Checker command ------------------------------------------*/
  63. Virus_Checker = "DH0:Tools/Virus/Virus_Checker"
  64. /*--------------------------------------------------------------------------*/
  65. options results
  66. options failat 99
  67. signal on syntax;signal on ioerr        /* Error trapping */
  68. parse arg DOpusPort source_handle.0 FilePath
  69. DOpusPort = Strip(DOpusPort,"B",'" ')
  70. source_handle.0 = Strip(source_handle.0,"B",'" ')
  71. FilePath = Strip(FilePath,"B",'" ')
  72.  
  73. If DOpusPort="" THEN Do
  74.     Say "Not correctly called from Directory Opus 5!"
  75.     Say "Load this ARexx script into an editor for more info."
  76.     EXIT
  77.     END
  78. If ~Show("P",DOpusPort) Then Do
  79.     Say DOpusPort "is not a valid port."
  80.     EXIT
  81.     End
  82. Address value DOpusPort
  83.  
  84. Quit_After = "NO"
  85. If ~Show("P","Virus_Checker") Then Do
  86.     Address Command Virus_Checker
  87.     Address Command "WaitForPort Virus_Checker"
  88.     Quit_After = "YES"
  89.     If ~Show("P","Virus_Checker") then do
  90.         dopus request '"Error loading Virus_Checker!'|| '0a'x ||'Check its command-path in the ARexx script itself." OK'
  91.         EXIT
  92.         END
  93.     END
  94.  
  95. /* If file/dir-path was specified on command line, check it, else
  96.    go through all the selected ones. */
  97.  
  98. BadList = ""
  99. BadNumber = 0
  100.  
  101. /*
  102. lister query source stem source_handle.
  103. IF source_handle.count = 0 | source_handle.count = "SOURCE_HANDLE.COUNT" Then Do
  104.     dopus request '"You must have a SOURCE lister!" OK'
  105.     EXIT
  106.     End
  107. */
  108.  
  109. If FilePath = "" Then Do
  110.     lister set source_handle.0 busy 1
  111.  
  112.     lister query source_handle.0 numselentries    /* Get info about selected */
  113.     Lister_NumSelEnt = RESULT            /* entries & path to them */
  114.     lister query source_handle.0 path
  115.     Lister_Path = Strip(RESULT,"B",'"')
  116.  
  117.     lister set source_handle.0 progress Lister_NumSelEnt "Checking for viruses..."
  118.  
  119.     Do i=1 to Lister_NumSelEnt
  120.         lister query source_handle.0 abort
  121.         If RESULT=1 Then BREAK
  122.         lister query source_handle.0 firstsel
  123.         Temp_Name = Strip(RESULT,"B",'"')
  124.         lister select source_handle.0 Temp_Name 0
  125.         Temp_Path = Lister_Path || Temp_Name
  126.         lister set source_handle.0 progress name Temp_Name
  127.         lister set source_handle.0 progress count i
  128.         Address "Virus_Checker" "Scan "||Temp_Path
  129.         If VCHECK.0.0 ~= 0 Then Do
  130.             command beep
  131.             Do x=1 to VCHECK.0.0
  132.                 BadNumber = BadNumber + 1
  133.                 BadList = BadList || '0a'x || VCHECK.x.1 ||"  (" || VCHECK.x.2 || ")"
  134.                 END
  135.             END
  136.         END
  137.     lister clear source_handle.0 progress
  138.     End
  139.  
  140. ELSE Do
  141.     lister set source_handle.0 progress "-1" "Checking for viruses..."
  142.     Address "Virus_Checker" "Scan "||FilePath
  143.     If VCHECK.0.0 ~= 0 Then Do
  144.         command beep
  145.         Do x=1 to VCHECK.0.0
  146.             BadNumber = BadNumber + 1
  147.             BadList = BadList || '0a'x || VCHECK.x.1 ||"  (" || VCHECK.x.2 || ")"
  148.             END
  149.         END
  150.     lister clear source_handle.0 progress
  151.     End
  152.  
  153. If BadNumber > 0 Then Do
  154.     If BadNumber = 1 Then
  155.         BadNote = "The following file is infected:"
  156.     Else
  157.         BadNote = "The following files are infected:"
  158.     BadList = "*VIRUS WARNING*" || '0a'x || BadNote || '0a'x || "(Virus name in parenthesis)" || '0a'x || BadList
  159.  
  160.     dopus request '"'||BadList||'" OK'
  161.  
  162. /* As there is only one gadget which returns "RC = 1", when "RC = 0" it means
  163.    that the requester failed to appear. This will happen when the list is too
  164.    long or wide to fit on the screen, which could easily happen with a virus
  165.    which has spread itself to many files!
  166.  
  167.    So, if the requester failed, the output will be sent to a shell window.
  168.    It would be nice to be able to use the user's defined output-window
  169.    size but there is (currently) no way of obtaining this. */
  170.  
  171.     IF RC = 0 Then Do
  172.         dopus request '"*VIRUS WARNING*' || '0a'x || 'List too large for requester' || '0a'x || 'and will be output to a shell..." OK'
  173.         Open(Output_Shell,"CON:0/1/640/200/Virus Warning/CLOSE/WAIT","W")
  174.         WriteLN(Output_Shell,BadList)
  175.         Close(Output_Shell)
  176.         END
  177.     END
  178.  
  179. /*-- Restore the Lister for normal use --------------------------------------*/
  180. syntax:;ioerr:                /* In case of error, jump here */
  181. END_PART_2:
  182.  
  183. lister clear source_handle.0 progress
  184.  
  185. If FilePath = "" Then Do
  186.     lister refresh source_handle.0
  187.     lister set source_handle.0 busy 0
  188.     END
  189.  
  190. END_PART:
  191. If Quit_After = "YES" Then Address "Virus_Checker" QUIT
  192.  
  193. EXIT
  194.